import { defineStore } from 'pinia'
import { getAllGroupById,getGroupDetail } from '@/api/groupHttp'

// 所有药品
export const useGroupStore = defineStore('group', {
  state: () => ({
    Groups:[{
      id: 1,
      name: '感冒药组合',
      medicines: ['布洛芬胶囊', '感冒灵颗粒', '板蓝根冲剂'],
      details: [{
        id: 1,
        name: '布洛芬胶囊',
        frequency: 0,
        dosage: '1',
        unit: '片',
        times: ['早餐后', '晚餐后']
      }, {
        id: 2,
        name: '感冒灵颗粒',
        frequency: 0,
        dosage: '1',
        unit: '包',
        times: ['早餐后', '午餐后', '晚餐后']
      }, {
        id: 3,
        name: '板蓝根冲剂',
        frequency: 1,
        dosage: '1',
        unit: '包',
        times: ['早餐后']
      }]
    }, {
      id: 2,
      name: '维生素组合',
      medicines: ['维生素C片', '维生素D片'],
      details: [{
        id: 4,
        name: '维生素C片',
        frequency: 0,
        dosage: '1',
        unit: '片',
        times: ['早餐后']
      }, {
        id: 5,
        name: '维生素D片',
        frequency: 1,
        dosage: '1',
        unit: '片',
        times: ['午餐后']
      }]
    }]
  }),
  
  getters: {
    
  },
  
  actions: {
    async getAllGroupById(){
      console.log(2);
      await getAllGroupById()
      return
      this.Groups = data
    },
    async getGroupDetailById(id){
      console.log(2);
      await getGroupDetail(id)
    }
  }
}) 